package com.plian.system.wrapper.pf;

import com.plian.system.dto.pf.SalaryDetailDTO;
import com.plian.system.entity.pf.SalaryDetail;
import com.plian.system.mybatis.support.BaseWrapper;
import com.plian.system.vo.pf.SalaryDetailVO;
import com.plian.system.wrapper.util.CacheWrapperUtil;
import com.plian.system.wrapper.util.WrapperUtil;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import static com.plian.system.wrapper.util.WrapperConstant.*;

/**
 * @description:
 * @author: gangan
 * @create: 2020-04-23 14:14
 */
@Mapper(componentModel = SPRING, uses = {CacheWrapperUtil.class, WrapperUtil.class})
public interface SalaryDetailWrapper extends BaseWrapper<SalaryDetail, SalaryDetailDTO, SalaryDetailVO> {

    /**
     * Entity转VO
     *
     * @param entity /
     * @return /
     */
    @Override
    @Mappings(value = {
            @Mapping(source = "rankId", target = "rankName", qualifiedByName = DICT_CODE_TO_NAME),
            @Mapping(source = "jobNameId", target = "jobNameId", qualifiedByName = STR_NULL_TO_EMPTY),
            @Mapping(source = "jobNameId", target = "jobNameName", defaultValue = ""),
            @Mapping(target = "departmentName", expression = "java(cacheWrapperUtil.checkLeader(entity.getDepartmentNameId(), entity.getIsLeader()))")
    })
    SalaryDetailVO entityToVO(SalaryDetail entity);
}
